﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Objects.DataClasses;

namespace ChampionFramework.Models
{
    public abstract partial class Etapa : EntityObject
    {
        public void Iniciar(ChampionContextContainer db)
        {
            this.Iniciada = true;
            db.ObjectStateManager.ChangeObjectState(this, System.Data.EntityState.Modified);
            db.SaveChanges();
        }

        public void Encerrar(ChampionContextContainer db)
        {
            if (this.GoToProximaEtapa(db) == null)
                this.Jogo.EncerrarJogoRegulamentar();
            this.Atual = false;
            this.Encerrada = true;
            db.ObjectStateManager.ChangeObjectState(this.Jogo, System.Data.EntityState.Modified);
            db.ObjectStateManager.ChangeObjectState(this, System.Data.EntityState.Modified);
            db.SaveChanges();
        }

        protected abstract Etapa GoToProximaEtapa(ChampionContextContainer db);
        public abstract string GetNome();
    }
}